package com.sondon.mayi.adapter;

import org.androidannotations.annotations.EViewGroup;
import org.androidannotations.annotations.ViewById;

import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.sondon.mayi.entity.Chat;
import com.sondon.mayi.fruit.R;
import com.sondon.mayi.ui.CircularImage;
import com.sondon.mayi.util.ImageLoaderUtil;
import com.sondon.mayi.util.PreferencesUtil;

/**
 * @Project : Fruit
 * @Package : com.sondon.mayi.adapter
 * @Class : MyChatList_Item
 * @Author : 蔡文锋
 * @DateTime：2015年7月6日 上午12:49:21
 * @Blog：http://blog.csdn.net/caiwenfeng_for_23
 * @Description : {  }
 *
 */
@EViewGroup(R.layout.mychatlist_item)
public class MyChatList_Item extends LinearLayout{
	private Context context;
	@ViewById
	LinearLayout chat_custom_layout;
	@ViewById 
	LinearLayout chat_user_layout;
	
//	@ViewById
//	TextView chat_custom_sender;
	@ViewById
	TextView chat_custom_send_time;
	@ViewById
	TextView chat_custom_content;
	
	@ViewById
	TextView caht_user_send_time;
	@ViewById
	TextView chat_user_content;
	@ViewById
	CircularImage chat_user_img;
	
	public MyChatList_Item(Context context) {
		super(context);
		this.context=context;
	}
	
	public void bind(Chat chat){
		//用户
		if(!TextUtils.isEmpty(chat.getUser_id())){
			chat_user_layout.setVisibility(View.VISIBLE);
			caht_user_send_time.setText(chat.getTime());
			chat_user_content.setText(chat.getContent());
			ImageLoaderUtil.SetImgView(PreferencesUtil.getStringValue("head_img"), chat_user_img);
		}else{
			chat_user_layout.setVisibility(View.GONE);
		}
		
		//客服
		if(!TextUtils.isEmpty(chat.getAdmin_id())){
			chat_custom_layout.setVisibility(View.VISIBLE);
			chat_custom_send_time.setText(chat.getRe_time());
			chat_custom_content.setText(chat.getRe_content());
		}else{
			chat_custom_layout.setVisibility(View.GONE);
		}
	}
	
	
}
